package com.library.gq.servce.impl;


import com.library.gq.dao.imlp.BookDaoImpl;
import com.library.gq.entity.BookEntity;
import com.library.gq.servce.BookServce;
import com.library.gq.util.Page;

import java.util.List;

public class BookServceImpl implements BookServce {
    BookDaoImpl bs = new BookDaoImpl();

    /**
     * 查询对象
     *
     * @param name        :物品
     * @param currentPage
     * @return page
     */
    @Override
    public Page<BookEntity> findByPage(String name, Integer currentPage) {
        //创建分页对象
        Page<BookEntity> page = new Page<>();
        //设置每页的行数
        page.setPageSize(5);
        //设置当前行数
        page.setCurrentPage(currentPage);
        //获取总记录调用Dao层区查询
        Integer i = bs.totalCount();
        //调用Dao查询当前页的数据集合
        page.setTotalCount(i);
        Integer start = (currentPage - 1) * page.getPageSize();
        List<BookEntity> list = bs.list(name, start, page.getPageSize());
        page.setList(list);
        return page;
    }

    @Override
    public Page<BookEntity> claim( Integer counttPate) {
        //创建分页对象
        Page<BookEntity> page = new Page<>();
        //设置每页的行数
        page.setPageSize(5);
        //设置当前行数
        page.setCurrentPage(counttPate);
        //获取总记录调用Dao层区查询
        Integer i = bs.totalCount();
        //调用Dao查询当前页的数据集合
        page.setTotalCount(i);
        Integer start = (counttPate - 1) * page.getPageSize();
        List<BookEntity> list = bs.list(start, page.getPageSize());
        page.setList(list);
        return page;
    }
}
